﻿@using ZBJF.Warranty.BLL
@using ZBJF.Warranty.Common.Enums
@using ZBJF.Warranty.Model
@using ZBJF.Warranty.WebProvider
@model ZBJF.Warranty.Model.ServiceProduct
@{
    var id = Model != null ? Model.ID : 0;
}
<ul class="nav nav-tabs">
    <li><a href="/Cleaning/ServiceProduct/ServiceProductIndex">服务商产品列表</a></li>
    <li class="active"><a href="/Cleaning/ServiceProduct/ServiceProductEdit/0">添加服务商产品</a></li>
</ul>
@using (Html.BeginForm("SaveServiceProduct", "ServiceProduct", FormMethod.Post, new { id = "inputForm", name = "inputForm", @class = "form-horizontal" }))
{
    @Html.HiddenFor(m => m.ID)
    <div class="control-group">
        <label class="control-label">服务商产品名称：</label>
        <div class="controls">
            @Html.TextBoxFor(m => m.ServiceProductName, new { validate = "{required:true,messages:{required:'请输入服务商产品名称'}}", maxlength = 20 })
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">服务商产品ID：</label>
        <div class="controls">
            @Html.TextBoxFor(m => m.ServiceProductId, new { validate = "{required:true,messages:{required:'请输入第三方服务商系统产品ID'}}", maxlength = 8, onkeyup = "onlyInputDecimal(this,0)" })
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">单价：</label>
        <div class="controls">
            @Html.TextBoxFor(m => m.ServiceProductPrice, new { validate = "{required:true,messages:{required:'请输入单价'}}", maxlength = 8, onkeyup = "onlyInputDecimal(this, 2)" })
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">所属服务商：</label>
        <div class="controls">
            @Html.DropDownListFor(m => m.ServiceId, ConvertToSelector.Instance.ServiceProviderConvertToSelectList(), new { validate = "{required:true,messages:{required:'请选择所属服务商'}}" })
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">中保清洗产品：</label>
        <div class="controls">
            @Html.DropDownListFor(m => m.LocalProductId, ConvertToSelector.Instance.CleaningProductConvertToSelectList(), new { validate = "{required:true,messages:{required:'请选择中保清洗产品'}}" })
        </div>
    </div>
        <div class="control-group">
            <label class="control-label"></label>
            <div class="controls">
                <label>
                    @Html.CheckBox("IsAvailable", Model == null?true: Model.IsAvailable)
                    是否可用
                </label>
            </div>
        </div>
        <div class="form-actions">
            <input id="btnSubmit" class="btn btn-primary Edit-R" type="button" value="保存" onclick="loading(this)">
            <input id="btnCancel" class="btn" type="button" value="重置" onclick="reset()">
        </div>
}

@section scripts{
    <script>
        function reset() {
            document.getElementById("inputForm").reset();
        }
        function loading(_this) {
            if ($("#inputForm").valid()) {
                _this.disabled = 'disabled';
                document.getElementById("inputForm").submit();
            }
        }
    </script>
}
